package site.codeyin.javautils.controller.excel;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.converters.WriteConverterContext;
import com.alibaba.excel.metadata.data.WriteCellData;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author <a href="https://github.com/liangcheng2221">yinjie</a>
 * @date 2024-09-07 10:25
 */
public class DataConvertor implements Converter<Date> {
    @Override
    public WriteCellData<?> convertToExcelData(WriteConverterContext<Date> context) throws Exception {
        return new WriteCellData<>(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(context.getValue()));
    }

}
